import java.util.Scanner;

public class demo05 {
    //顺子日期
    public static void main(String[] args) {
        int count=0;
        for (int i = 20220101; i <20230000 ; i++) {
            if(check(i)){
                if(func(i)){
                    count++;
                }
            }
        }
        System.out.println(count);
    }
    public static boolean check(int i){
        int year=i/10000;
        i%=10000;
        int month=i/100;
        int day=i%100;
        int[] arr={0,31,28,31,30,31,30,31,31,30,31,30,31};
        if((year%4==0&&year%100!=0)||(year%400==0)){
            arr[2]++;
        }
        if(month>=1&&month<=12){
            if(day>=1&&day<=arr[month]){
                return true;
            }
        }
        return false;
    }
    public static boolean func(int i){
        String str=i+"";
        int n=1;
        for (int j = 0; j < str.length()-1; j++) {
            if(str.charAt(j)+1==str.charAt(j+1)){
                n++;
            }else{
                n=1;
            }
            if(n==3){
                return true;
            }
        }
        return false;
    }
}